﻿<UserControl x:Class="Caffeine.Examples.Contacts.View.ContactSnapshotView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:presentationCore="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
    <Border Padding="3" BorderThickness="1" CornerRadius="5" Margin="5">
        <Border.Style>
            <Style TargetType="Border">
                <Setter Property="Background" Value="#CCCCCC" />
                <Setter Property="BorderBrush" Value="DarkGray" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelected.Value}" Value="True">
                        <Setter Property="Background" Value="#819FF7" />
                        <Setter Property="BorderBrush" Value="#0040FF" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
        <Grid Margin="2" IsHitTestVisible="True" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel HorizontalAlignment="Left">
                <WrapPanel>
                    <TextBox DataContext="{Binding FirstName}" 
                             Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" 
                             Margin="3,0,3,3" 
                             Width="140"
                             Style="{DynamicResource ValidatedTextBox}" />
                    <TextBlock Style="{DynamicResource ChangeNotificationText}" 
                               DataContext="{Binding FirstName}" />
                </WrapPanel>
                <WrapPanel>
                    <TextBox DataContext="{Binding LastName}" 
                             Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" 
                             Margin="3,0,3,3" 
                             Width="140"
                             Style="{DynamicResource ValidatedTextBox}" />
                    <TextBlock Style="{DynamicResource ChangeNotificationText}" 
                               DataContext="{Binding LastName}" />
                </WrapPanel>
            </StackPanel>
            <StackPanel Grid.Column="1" Margin="0,0,5,0" HorizontalAlignment="Right">
                <Button Margin="0,3,0,0"
                        Command="{Binding Remove}" 
                        VerticalAlignment="Top" 
                        HorizontalAlignment="Right"
                        Visibility="{Binding IsCommittedToCollection, Converter={StaticResource BooleanToVisibilityConverter}}"
                        Style="{DynamicResource RemoveButton}" 
                        ToolTip="Remove Contact" />
                <Button Margin="0,3,0,0"
                        Command="{Binding Remove}" 
                        VerticalAlignment="Top" 
                        HorizontalAlignment="Right"
                        Visibility="{Binding IsAddedToCollection, Converter={StaticResource BooleanToVisibilityConverter}}"
                        Style="{DynamicResource CancelButton}" 
                        ToolTip="Cancel Adding Contact" />
                <WrapPanel HorizontalAlignment="Right">
                    <Button Margin="0,5,0,0"
                            Command="{Binding Save}" 
                            VerticalAlignment="Top" 
                            ToolTip="Save Contact"
                            Style="{StaticResource SaveButton}" />
                    <Button Margin="5,5,0,0"
                            Command="{Binding UndoChanges}" 
                            VerticalAlignment="Top" 
                            HorizontalAlignment="Right"
                            Visibility="{Binding IsDirty, Converter={StaticResource BooleanToVisibilityConverter}}"
                            Style="{DynamicResource UndoButton}" 
                            ToolTip="Undo contact changes" />
                </WrapPanel>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
